<?php

/* @auther wf
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class ZMembership {

    public $conn;

    public function __construct() {
        $this->conn = Yii::app()->db;
    }

    //获取所有学生在籍人数
    static public function _getMembershipAll($serch) {
        $sql = ' SELECT "membership_id","membership_name","membership_code","edu_type","description","disabled" FROM "{{membership}}" ';
        $sqlcount = ' SELECT count(*) FROM "{{membership}}" ';
        $where = ' WHERE "membership_id" > 0  AND "is_del" = 0 ';
        if (Func::check_search($serch['membership_code'])) {
            $where .= ' AND "membership_code" like \'%'.$serch['membership_code'].'%\'';
        }
        if (Func::check_search($serch['membership_name'])) {
            $where .= ' AND "membership_name" LIKE  \'%'. $serch['membership_name'] .'%\'';
        }
        $where.= ' ORDER BY "membership_code" ';
        $data = ZCommon::getDaoPageList($sql . $where, $sqlcount . $where, 8);
        return $data;
    }

    //获取所有在籍人数类型
   static public function _getAllmembershiptype() {
        $sql = ' SELECT "mt_id","mt_name","mt_code","mt_type" FROM "{{membership_type}}" WHERE "mt_id" >0  ';
        $data = Yii::app()->db->createcommand($sql)->queryAll();
        return $data;
    }
    
     //获取所有在籍人数类型
   static public function _getAllmembershiptypenum($where=false) {
        $sql = ' SELECT "mn_id","school_id","membership_id","mt_id","mt_num" FROM "{{membership_num}}" WHERE "mn_id" >0 ';
        if($where){
            $sql .= " AND ".$where;
        }
        $data = Yii::app()->db->createcommand($sql)->queryAll();
        return $data;
    }

}